<template>
  <mt-datetime-picker ref="picker" id="picker" type="date" v-model="pickerValue"
                      @confirm="handleChange"></mt-datetime-picker>
</template>

<script>
  /**
   * @module common/plugins/datePicker
   * @author ashen
   * @description  datePicker交互组件，调用方法为：调用state中的setDatePiker(param)方法
   * @example this.$store.dispatch('setDatePiker', {
          value: '2017-09-18',
          method: function (result) {
            console.log('您选取的时间是:' + result);
          }
        });
   */
  export default {
    data () {
      return {};
    },
    computed: {
      pickerValue: {
        get: function () {
          return this.$store.state.mintUI.pickerValue;
        },
        set: function () {
        }
      }
    },
    methods: {
      openPicker () {
        this.$refs.picker.open();
      },
      handleChange (value) {
        this.$store.state.mintUI.pickerCallback(value);
        //this.$store.dispatch('setDatePiker', value);
      }
    },
    mounted: function () {
      this.$store.dispatch('setPicker', this.$refs.picker);
    }
  };
</script>

<style>
</style>
